<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"[]>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
<head>
<META http-equiv="Content-Type" content="text/html; CHARSET=UTF-8">
<?php
  require_once '../header.php';
  session_start();
  ob_start();
  if (!(isset($_SESSION["userid"])))
  {
  	header("Location: index.php");
  }
  if(isset($_POST["sid"])) { $idPoem = $_POST["sid"]; }
  if(isset($_POST["title"])) { $title = $_POST["title"]; }
  if(isset($_POST["content"])) { $content = $_POST["content"]; }
  if(isset($_POST["music"])) { $music = $_POST["music"]; }
  if(isset($_POST["lyrics"])) { $lyrics = $_POST["lyrics"]; }
  if(isset($_POST["youtubeCode"])) { $youtubeCode = $_POST["youtubeCode"]; }
  if(isset($_POST["category"])) { $category = $_POST["category"]; }
  if(isset($_POST["album"])) { $album = $_POST["album"]; }

  try
  {
    $ConnectDB = new connectDB();
    $SQLList = new sqlList();
    $result = $ConnectDB->buildPreparedStatments($SQLList->UpdatePoemById);
    $result->bind_param( 'sssssi', $title, $content, $music, $lyrics, $youtubeCode, $idPoem );
    $result->execute();
    $result->close();
    header("Location: /poem/song.php?sid=$idPoem");
  }
  catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}

?>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>詩歌-主頁</title>
</head>
<body>

<table border="0">
<tr>
      					<td>詩歌ID : </td>
      					<td>
      						<input type="text" title="title" name="title" id="title" value="<?php print $idPoem;?>" size=80  />
      					</td>
    					</tr>
							<tr>
      					<td>詩歌 : </td>
      					<td>
      						<input type="text" title="title" name="title" id="title" value="<?php print $title;?>" size=80  />
      					</td>
    					</tr>
    					<tr>
      					<td>專輯 : </td>
      					<td>
      						<input type="text" title="album" name="album" id="album" value="<?php print $album;?>" size=80  />
      					</td>
    					</tr>
    					<tr>
      					<td>作曲 : </td>
      					<td>
      						<input type="text" title="music" name="music" id="music" value="<?php print $music;?>" size=80  />
      					</td>
    					</tr>
    					<tr>
      					<td>作詞 : </td>
      					<td>
      						<input type="text" title="lyrics" name="lyrics" id="lyrics" value="<?php print $lyrics;?>" size=80  />
      					</td>
    					</tr>
    					<tr>
      					<td style="vertical-align:top;">歌詞 :</td>
      					<td>
    							<textarea rows="20" cols="80" name="content"><?php print $content; ?></textarea>
    						</td>
    					</tr>
    					<tr>
      					<td>Youtube Code : </td>
      					<td>
      						<input type="text" title="youtubeCode" name="youtubeCode" id="youtubeCode" value="<?php print $youtubeCode;?>" size=80  />
      					</td>
    					</tr>
    					<tr>
      					<td>分類 : </td>
      					<td>
      						<input type="text" title="category" name="category" id="category" value="<?php print $category;?>" size=80  />
      					</td>
    					</tr>
    					<tr>
      					<td colspan="2" style="text-align: right;">
      						<input type="submit" value="儲存"/>
      					</td>
    					</tr>
						</table>

</body>
</html>
